package com.woniu.market_stall.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.market_stall.mapper.StallMapper;
import com.woniu.market_stall.vo.AuctionStallVo;
import com.woniu.market_stall.vo.StallVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuctionStallService {
    @Autowired
    StallMapper stallMapper;

    /**
     * 按照条件查询摊位
     * @param now 当前页面
     * @param size 页面大小
     * @param status 状态
     * @param marketId 市场id
     * @param stallName 摊位名字
     * @return 返回一个PageInfo
     */
    public PageInfo<AuctionStallVo> queryAuctionStallByPage(Integer now , Integer size , String status , String marketId , String stallName){
        PageHelper.startPage(now , size);
        List<AuctionStallVo> list = stallMapper.selectAuctionStallByCons(status, marketId , stallName);
        return new PageInfo<>(list);
    }

    public void add(AuctionStallVo auctionStallVo) {
        stallMapper.insertAuctionStall(auctionStallVo);

    }

    public void modify(AuctionStallVo auctionStallVo) {
        stallMapper.updateAuctionStallById(auctionStallVo);
    }

    public void del(int id) {

        stallMapper.deleteAuctionStallById(id);
    }
}
